﻿using System;
using System.Collections;
using System.Data;
using CE.Database;

/// <summary>
/// Summary description for TAPremiumDB
/// </summary>
/// 
namespace CE.TravelInsurance
{
    public class TAPremiumDB
    {
        public TAPremiumDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(TAPremium tapremium, string covertype)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocTAPremiumInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();
            #region Parameter

            _sPara.Add("@TAPreID", tapremium.TAPreId);
            _sPara.Add("@TAInsID", tapremium.TAInsId);
            _sPara.Add("@AreaID", tapremium.AreaId);
            _sPara.Add("@DurationStart", tapremium.DurationStart);
            _sPara.Add("@DurationEnd", tapremium.DurationEnd);
            _sPara.Add("@Subsequent", tapremium.Subsequent);
            _sPara.Add("@Price", tapremium.Price);
            _sPara.Add("@CoverType", covertype);

            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public void  Delete(Int64 TAPreID, string covertype)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "sprocTAPremiumDeleteSingleItem";

            SortedList _sPara = new SortedList();
            #region Parameter

            _sPara.Add("@TAPreID", TAPreID);
            _sPara.Add("@CoverType", covertype);
            #endregion

            _db.ExecuteSP(_spName, _sPara);

        }

        public DataTable GetPremiumDTList(Int64 TACompanyId, string covertype, string coveragelevel, Int64 AreaId)
        {
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable("Result");
            string _spName = "sprocTASelectPremiumItemList";
            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@TACompanyId", TACompanyId);
            _sPara.Add("@CoverType", covertype);
            _sPara.Add("@CoverageLevel", coveragelevel);
            _sPara.Add("@AreaId", AreaId);
            #endregion

            _dtResult = _db.GetDataTableBySP(_spName, _sPara);
            return _dtResult;
        }

        public DataTable GetPremiumDTItem(Int64 TAPreId, string covertype)
        {
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable("Result");
            string _spName = "sprocTASelectPremiumInfoSingleItem";
            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@TAPreId", TAPreId);
            _sPara.Add("@CoverType", covertype);
            #endregion

            _dtResult = _db.GetDataTableBySP(_spName, _sPara);
            return _dtResult;
        }
    }
}
